#include<iostream>
#include "Bubble.h"
using namespace std;


void Bubble::sort(int* a,int len){
	for (int i = 0; i < len-1; i++)
	{
		for (int j = 0; j < len-1-i; j++)
		{
			if (greater(a[j], a[j + 1])) {
				exch(a, j, j + 1);
			}
		}
	}
}

bool Bubble::greater(int v, int w) {
	if (v > w) {
		return true;
	}
	else
	{
		return false;
	}
}

void Bubble::exch(int* arr, int i, int j) {
	int temp = arr[i];
	arr[i] = arr[j];
	arr[j] = temp;
}


void main03() {
	int a[] = { 6,5,4,3,2,1 };
	int len = sizeof(a) / sizeof(a[0]);
	Bubble b;
	b.sort(a, len);
	for (int i = 0; i < len; i++)
	{
		cout << a[i] << endl;
	}
}
